﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;

namespace PRET.PRETService
{
    static class Program
    {
        private readonly static string ApplicationName = "{052EDB72-3E31-45D2-BF6D-8B21223A5D95}";
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            bool runone = false;
            using (System.Threading.Mutex run = new System.Threading.Mutex(true, "Global\\" + ApplicationName, out runone))
            {
                if (runone)
                {
                    // 没有相同程序正在运行
                    ServiceBase[] ServicesToRun;
                    ServicesToRun = new ServiceBase[] 
                    { 
                        new PRETService() 
                    };
                    ServiceBase.Run(ServicesToRun);
                }
                else
                {
                    // 有相同的程序正在运行
                    return;
                }
            }            
        }
    }
}
